Decomposing into Bézier form

Test Cases for the Procedure Decompose

1) The first test of the decomposition algorithms is the case given in The NURBS Book's Figure 5.18-19.

Figure 5.18 Figure 5.19

The following program tests the decomposition algorithm for curves by reproducing the case demonstrated above.

program test_curve_decomposition

use splines
use points

implicit none
integer, parameter :: wp  = selected_real_kind(15,307)
logical, parameter :: T = .true.
logical, parameter :: F = .false.
type(curve), allocatable :: segments(:)
type(cpt) :: cp(7)
real(wp) :: U(11),X(6)
type(curve) :: crv

cp(:)%x = [ 0.00_wp,  0.10_wp,  1.90_wp,  2.40_wp,  4.00_wp,  4.40_wp,  3.50_wp]
cp(:)%y = [ 0.20_wp,  2.30_wp,  2.50_wp,  0.00_wp,  0.00_wp,  1.50_wp,  3.00_wp]

U=[0.0_wp,0.0_wp,0.0_wp,0.0_wp,1.0_wp,2.0_wp,3.0_wp,4.0_wp,4.0_wp,4.0_wp,4.0_wp]

crv = spl(dim=2, pd=1, p=[3], kXi=U, cp=cp)

call crv%Decompose(BC=segments)  

call plot(  me=[crv,segments],  &    !<= since the declared types of actual arguments are different,
                                    !   w/o select type argument "me" is invalid.
            plotCP=T, labelCP=T,                &
            plotElems=T,                        &
            terminal='png', fname="test_F5.18-19", &
            title="Decomposition of the curve into its Bézier segments" )

pause

end program test_curve_decomposition

The resulting plot is as follow,


Figure 5.18-19


2) The second test of the decomposition algorithms is the case given in The NURBS Book's Figure 5.20-21.

Figure 5.20 Figure 5.21

program test_surface_decomposition

use splines
use points

implicit none

integer, parameter :: wp  = selected_real_kind(15,307)
logical, parameter :: T = .true.
logical, parameter :: F = .false.
type(surface) :: surf
type(surface), allocatable :: segments(:,:)
type(cpt) :: scp(20)
real(wp) :: U(9), V(7)

scp(:)%x = [ 1.0,  1.0,  1.0,  1.0,  1.0,  0.2,  0.2,  0.2,  0.2,  0.2, &
   -0.2, -0.2, -0.2, -0.2, -0.2, -1.0, -1.0, -1.0, -1.0, -1.0]
scp(:)%y = [-1.0, -0.3,  0.0,  0.7,  1.0, -1.0, -0.3,  0.0,  0.7,  1.0, &
   -1.0, -0.3,  0.0,  0.7,  1.0, -1.0, -0.3,  0.0,  0.7,  1.0]
scp(:)%z = [ 1.0,  1.0, -0.2, -2.0, -2.0,  1.0,  1.0, -0.2, -2.0, -2.0, &
   3.0,  3.0,  2.0,  1.0,  1.0,  3.0,  3.0,  2.0,  1.0,  1.0]

U = [0.0_wp,0.0_wp,0.0_wp,0.0_wp,0.60_wp,1.0_wp,1.0_wp,1.0_wp,1.0_wp]
V = [0.0_wp,0.0_wp,0.0_wp,0.40_wp,1.0_wp,1.0_wp,1.0_wp]

surf = spl(dim=3, pd=2, p=[3,2], kXi=U, kEta=V, cp=scp)

call surf%Decompose(BS=segments)

call surf%plot(     plotCP=T,                                                   &
                  plotElems=T,                                                &
                  plotOpt=["set colorsequence classic","set view ,120"],      &
                  terminal='wxt', fname="test_F5.20",                         &
                  title="A (cubic x quadratic) surface to be decomposed"      )

call plot(  me=[segments],                                                &
            plotCP=T,                                                   &
            plotElems=T,                                                &
            plotOpt=["set colorsequence classic","set view ,120"],      &
            terminal='wxt', fname="test_F5.21",                         &
            title="Piecewise Bezier patches after decomposition"        )

pause
end program test_surface_decomposition

Figure 5.20


Figure 5.21